﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spanner;

namespace SpannerWebSite
{
    internal partial class RefDates : Reference
    {
        internal static SpannerChapter TheChapter;

        static RefDates()
        {
            var sections = new List<SpannerSection> { };
            var initActs = new List<Act> { };

            Action<string, string, Html> addSection = (title, id, html) =>
            {
                sections.Add(Section(Esc(title), id, html));
            };

            addSection("NewDate", "NewDate", P(Code("NewDate()"), " denotes the JavaScript ",
                Code("new Date()"), "."));

            addSection("NewDate milliseconds", "NewDateMs", P(Code("NewDate(ms)"), " denotes the JavaScript ",
                Code("new Date(ms)"), "."));

            addSection("NewDate string", "NewDateStr", P(Code("NewDate(dateStr)"), " denotes the JavaScript ",
                Code("new Date(dateStr)"), "."));

            addSection("NewDate parts", "NewDateParts", P(Code("NewDate(year, month, day, hour, minute, second, ms)"), " denotes the JavaScript ",
                Code("new Date(year, month, day, hour, minute, second, ms)"), " (any prefix of the parameter ",
                "list after the year may be supplied, for example, ", Code("NewDate(2014, 6)"), "."));

            addSection("NewUtcDate", "NewUtcDate", P(Code("NewUtcDate(year, month, day, hour, minute, second, ms)"), " denotes the JavaScript ",
                Code("new Date(Date.UTC(year, month, day, hour, minute, second, ms))"), " (any prefix of the parameter ",
                "list after the year may be supplied, for example, ", Code("NewUtcDate(2014, 6)"), "."));

            addSection("MillisecondsAtUtcDate", "NewUtcDate", P(Code("MillsecondsAtUtcDate(year, month, day, hour, minute, second, ms)"), " denotes the JavaScript ",
                Code("Date.UTC(year, month, day, hour, minute, second, ms)"), " (any prefix of the parameter ",
                "list after the year may be supplied, for example, ", Code("MillisecondsAtUtcDate(2014, 6)"), "."));

            addSection("ParseDate", "ParseDate", P(Code("ParseDate(dateStr)"), " denotes the JavaScript ",
                Code("Date.parse(dateStr)"), "."));

            addSection("GetXYZ, GetUtcXYZ, SetXYZ, SetUtcXYZ", "GetSet", P(Code("GetXYZ(x)"), " ",
                "denotes the JavaScript ", Code("x.getXYZ()"), "; ", Code("SetXYZ(x, y)"), " ",
                "denotes the JavaScript ", Code("x.setXYZ(y)"), " where ", Code("XYZ"), " ",
                "is any of ",
                Code("Date"), ", ",
                Code("Day"), ", ",
                Code("FullYear"), ", ",
                Code("Hours"), ", ",
                Code("Milliseconds"), ", ",
                Code("Minutes"), ", ",
                Code("Month"), ", ",
                Code("Seconds"), ", ",
                Code("Time"), "."));

            addSection("ToDateString", "ToDateString", P(Code("ToDateString(x)"), " denotes the JavaScript ",
            Code("x.toDateString()"), "."));

            addSection("ToLocaleDateString", "ToLocaleDateString", P(Code("ToLocaleDateString(x)"), " denotes the JavaScript ",
            Code("x.toLocaleDateString()"), "."));

            addSection("ToLocaleFormat", "ToLocaleFormat", P(Code("ToLocaleFormat(x)"), " denotes the JavaScript ",
            Code("x.toLocaleFormat()"), "."));

            addSection("ToLocaleString", "ToLocaleString", P(Code("ToLocaleString(x)"), " denotes the JavaScript ",
            Code("x.toLocaleString()"), "."));

            addSection("ToLocaleTimeString", "ToLocaleTimeString", P(Code("ToLocaleTimeString(x)"), " denotes the JavaScript ",
            Code("x.toLocaleTimeString()"), "."));

            addSection("ToTimeString", "ToTimeString", P(Code("ToTimeString(x)"), " denotes the JavaScript ",
            Code("x.toTimeString()"), "."));

            addSection("ToUtcString", "ToUtcString", P(Code("ToUtcString(x)"), " denotes the JavaScript ",
            Code("x.toUtcString()"), "."));

            TheChapter = CommonUI.Chapter("Reference - Dates", "RefDates", sections, initActs);
        }
    }
}
